
<div class="panel panel-default panel-intro">

    <div class="panel-body">
        <h3>客户自定义分析
            {eq name="$type" value="bar" }<a style="font-size: 14px" href="javascript:location.href=location.href+'&type=pie';"><i class="fa fa-bar-chart"></i> 切换为饼状图</a>{else/}<a href="javascript:location.href=location.href+'&type=bar';" style="font-size: 14px"><i class="fa fa-bar-chart"></i> 切换为柱状图</a>{/eq}</h3>
       <div class="col-sm-12 col-xs-12">
           <form name="search-form" role="form" method="get" data-toggle="validator"
                 class="form-horizontal col-sm-12" action="">
               <div class="form-group">
                   <div class="col-xs-12 col-sm-12">
                       <div class="input-group">
                           <select class="form-control selectpicker"  name="row[field]" style="width: 200px;margin: 10px" >
                               {foreach name="fields" item="val"}
                               <option value="{$val.id}" {eq name="field" value="$val.id"}selected="selected"{/eq} >
                               {$val.name}</option>
                               {/foreach}
                           </select>
                           <input class="form-control datetimerange"
                                  placeholder="指定日期" autoComplete='off'
                                  data-locale='{"format":"YYYY-MM-DD"}'
                                  style="width: 200px;margin: 10px" name="row[times]" value="{$times}" type="text">

                           <select class="form-control selectpicker" name="row[group_id]" data-live-search="true" style="width: 200px;margin: 10px" >
                               <option value="">全部</option>
                               {foreach name="groupdata" item="val"}
                               <option value="{$val.id}" {eq name="group_id" value="$val.id"}selected="selected"{/eq} >{$val.name}</option>
                               {/foreach}
                           </select>

                           <input id="c-lesson_id" class="form-control" name="row[area_id]" data-field="cont" placeholder="请选择学科类目" type="text" value="{$row.lesson_id|htmlentities}"  style="width: 200px;margin: 10px!important;">

                           <input id="c-age" class="form-control" name="row[area_id]" data-field="cont" placeholder="请选择学员年龄" type="text" value="{$row.age|htmlentities}"  style="width: 200px;margin: 10px!important;">

                           <input data-source="qingdongams/statistic/customers/getstaff" placeholder="全部员工" class="form-control selectpage"  data-pagination="true" style="width: 200px;margin: 10px!important;" name="row[staff_id]" type="text" value="{$staff_id}">

                           <input id="c-area_id" data-source="jieziarea/index?level_egt=2" class="form-control selectpage" name="row[area_id]" data-field="cont" placeholder="请选择地区" type="text" value="{$row.area_id|htmlentities}"  style="width: 200px;margin: 10px!important;">

                           <button type="submit" class="btn btn-success" style="margin: 10px" >立即搜索</button>
                       </div>
                   </div>
               </div>
           </form>
       </div>
        <div class="col-sm-8 col-xs-12 {if condition='!$multiple'}hide{/if}">
            <div class="alert alert-warning alert-dismissible" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <strong>多选项!</strong> 当前字段可以`多选`，所以不同选项的客户统计会重复!
            </div>
        </div>
        <div class="col-xs-6 col-sm-6">
            <div class="div-box">
                <div style="padding-top: 15px;padding-left:15px;margin-bottom:10px;">

                </div>
                <div id="echart" style="width:100%;height: 457px"></div>
            </div>
        </div>
        <div class="col-xs-6 col-sm-6">
            <table id="table" class="table table-striped table-bordered table-hover table-nowrap" width="100%" style="">
                <thead>
                <tr class="qd_table_color">

                    <th>
                        {$field_name}
                    </th>
                    <th>
                        个数
                    </th>
                    <th>
                        占比
                    </th>
                </tr>
                </thead>
                <tbody>
                    {foreach name="list" item="val"}
                        <tr>
                            <td>{$val.name}</td>
                            <td>{if condition="$val.number"}
                                <a href="qingdongams/customer/customer/index?{$field}={$val.name}&createtime={$times}&group_id={$group_id}&owner_staff_id={$staff_id}"  class="btn-dialog" data-title="客户自定义分析" >{$val.number}</a>
                                {else/}
                                    {$val.number}
                                {/if} </td>
                            <td>{$val.ratio}%</td>
                        </tr>
                    {/foreach}
                </tbody>
            </table>
        </div>
    </div>
</div>


<script>
    var Orderdata = {
        customerdata:{:json_encode($customerdata)}
    };
</script>